/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sysdental.view;

import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import sysdental.manager.PersonaManager;
import sysdental.to.PersonaTO;
import sysdental.to.TratamientoTO;

/**
 *
 * @author Alumno
 */
public class frmAgenda extends javax.swing.JFrame {
    PersonaTO p=new PersonaTO();
    PersonaManager ma=new PersonaManager();
    /**
     * Creates new form frmAgenda
     */
    public frmAgenda() {
        initComponents();
        cargar_combo_personas();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cboPersona = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(245, Short.MAX_VALUE)
                .addComponent(cboPersona, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addComponent(cboPersona, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(278, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cboPersona;
    // End of variables declaration//GEN-END:variables

    private void cargar_combo_personas() {
        try {
            Iterator<PersonaTO> rs=ma.listar().iterator();
            
            while(rs.hasNext()){
                p=rs.next();
                cboPersona.addItem(p.getId_persona()+"-"+p.getNom_pe());
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane,ex.getMessage());
        }
    }
}
